define(['common/js/boss-frame-angular-dev-0.1'],function() {
	serviceModule.factory("plusMap", function () {
		function Map() {
			this.container = new Object();
		};

		Map.prototype.put = function (key, value) {
			this.container[key] = value;
		};

		Map.prototype.get = function (key) {
			return this.container[key];
		};

		Map.prototype.keySet = function () {
			var keyset = new Array();
			var count = 0;
			for (var key in this.container) {
				// 跳过object的extend函数
				if (key == 'extend') {
					continue;
				}
				keyset[count] = key;
				count++;
			}
			return keyset;
		};

		Map.prototype.size = function () {
			var count = 0;
			for (var key in this.container) {
				// 跳过object的extend函数
				if (key == 'extend') {
					continue;
				}
				count++;
			}
			return count;
		};

		Map.prototype.remove = function (key) {
			delete this.container[key];
		};

		Map.prototype.toString = function () {
			var str = "";
			for (var i = 0, keys = this.keySet(), len = keys.length; i < len; i++) {
				str = str + keys[i] + "=" + this.container[keys[i]] + ";\n";
			}
			return str;
		};

		return Map;
	});
	
	serviceModule.factory("CharUtil", function () {
		return {
			/**
			 * 判断对象是否为空
			 */
			checkIsNull : function(obj,yours){
				obj = $.trim(obj);
				if(yours != null && yours.length > 0){
					for(var i=0;i<yours.length;i++){
						if(obj == yours[i]){
							return true;
						}
					}
				}else{
					if(!obj 
							|| obj == null 
							|| obj == undefined 
							|| obj==""){
						return true;
					}
				}
			}
		}
	});
	
	serviceModule.factory("DateUtil", function () {
		return {
			/**
			 * 获取目标日期
			 */
			getTargetShowTime : function(param){
				var firstShowStart = param.firstShowStart;
				var firstShowEnd = param.firstShowEnd;
				var intervalDay = param.intervalDay;
				var frequency = param.frequency;
				
				if(firstShowStart.length == 16){
					firstShowStart =firstShowStart + ":00";
				}
				if(firstShowEnd.length == 16){
					firstShowEnd =firstShowEnd + ":00";
				}
				
				var date1 = new Date(Date.parse(firstShowStart.replace(/-/g, "/")));
				var date2 = new Date(Date.parse(firstShowEnd.replace(/-/g, "/")));
				var days = parseInt(intervalDay * frequency );
				
				var mills1 = date1.getTime() + 24 * 3600 * 1000 * days;
				var mills2 = date2.getTime() + 24 * 3600 * 1000 * days;
				var nextDate1 = new Date(date1.getTime() + 24 * 3600 * 1000 * days);
				var nextDate2 = new Date(date2.getTime() + 24 * 3600 * 1000 * days);
				
				var year1 = parseInt(nextDate1.getFullYear());
				var month1 = parseInt(nextDate1.getMonth()) + 1 < 10 ? "0"+(parseInt(nextDate1.getMonth()) + 1): parseInt(nextDate1.getMonth()) + 1
				var day1 = parseInt(nextDate1.getDate()) < 10 ? "0"+parseInt(nextDate1.getDate()):parseInt(nextDate1.getDate());
				var hour1 = parseInt(nextDate1.getHours()) < 10 ? "0"+parseInt(nextDate1.getHours()):parseInt(nextDate1.getHours());
				var minute1 = parseInt(nextDate1.getMinutes()) < 10 ? "0"+parseInt(nextDate1.getMinutes()):parseInt(nextDate1.getMinutes());
				
				var year2 = parseInt(nextDate2.getFullYear());
				var month2 = parseInt(nextDate2.getMonth()) + 1 < 10 ? "0"+(parseInt(nextDate2.getMonth()) + 1): parseInt(nextDate2.getMonth()) + 1;
				var day2 = parseInt(nextDate2.getDate()) < 10 ? "0"+parseInt(nextDate2.getDate()):parseInt(nextDate2.getDate());
				var hour2 = parseInt(nextDate2.getHours()) < 10 ? "0"+ parseInt(nextDate2.getHours()) : parseInt(nextDate2.getHours());
				var minute2 = parseInt(nextDate2.getMinutes()) < 10 ? "0" +parseInt(nextDate2.getMinutes()):parseInt(nextDate2.getMinutes());
				
				var weekName1 = new Date(year1,parseInt(month1-1),day1).getDay();   
				var weekName2 = new Date(year2,parseInt(month2-1),day2).getDay();
				
				var timeChin = ["日","一", "二", "三", "四", "五", "六"];
				var result = {
					"targetShowTime":year1+"-"+month1+"-"+day1+" "+hour1+":"+minute1,
					"targetShowEndTime":year2+"-"+month2+"-"+day2+" "+hour2+":"+minute2,
					"showTimeWeek":year1+"-"+month1+"-"+day1+" 星期"+timeChin[weekName1]+" "+hour1+":"+minute1 +" 至 " +
							year2+"-"+month2+"-"+day2+" 星期"+timeChin[weekName2]+" "+hour2+":"+minute2,
					"showTimeMillis":mills1,
					"showEndTimeMillis":mills2
				};
				if(day1 == day2){
					result.showTimeWeek = 
						year1+"-"+month1+"-"+day1+" 星期"+timeChin[weekName1]+" "+hour1+":"+minute1 + " 至 " + hour2+":"+minute2;
				}
				return result;
			}
		}
	});
	
	/***
	 * 数字运算 工具类
	 */
	serviceModule.factory("PlusMathUtil", function() {

		return {
			/***
			 *乘法
			 */
			multiply : function(a, b) {
				var c = 0, d = a.toString(), e = b.toString();
				try {
					c += d.split(".")[1].length;
				} catch (f) {
				}
				try {
					c += e.split(".")[1].length;
				} catch (f) {
				}
				return Number(d.replace(".", "")) * Number(e.replace(".", ""))
						/ Math.pow(10, c);
			},

			/**
			 * 减法
			 */
			subtract : function(a, b) {

				var c, d, e;
				try {
					c = a.toString().split(".")[1].length;
				} catch (f) {
					c = 0;
				}
				try {
					d = b.toString().split(".")[1].length;
				} catch (f) {
					d = 0;
				}
				return e = Math.pow(10, Math.max(c, d)),
						(this.multiply(a, e) - this.multiply(b, e)) / e;

			},
			/***
			 * 加法
			 */
			add : function(a, b) {
				var c, d, e;
				try {
					c = a.toString().split(".")[1].length;
				} catch (f) {
					c = 0;
				}
				try {
					d = b.toString().split(".")[1].length;
				} catch (f) {
					d = 0;
				}
				return e = Math.pow(10, Math.max(c, d)),
						(this.multiply(a, e) + this.multiply(b, e)) / e;
			},

			/**
			 * 除法
			 */
			divide : function(a, b) {
				var c, d, e = 0, f = 0;
				try {
					e = a.toString().split(".")[1].length;
				} catch (g) {
				}
				try {
					f = b.toString().split(".")[1].length;
				} catch (g) {
				}
				return c = Number(a.toString().replace(".", "")), d = Number(b
						.toString().replace(".", "")), $scope.mul(c / d, Math.pow(
						10, f - e));
			}
		};

	});
});